package cn.pzhu.services.web;

import cn.pzhu.model.College;
import cn.pzhu.model.Company;
import cn.pzhu.model.Expert;
import cn.pzhu.model.PageBean;
import cn.pzhu.services.BaseServices;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by dongp on 2016/5/19.
 */
public class WebCompanyServices extends BaseServices {

	public List<Company> queryCompany(HttpServletRequest request){
		// session获取分页参数
		HttpSession session = request.getSession();
		PageBean pageBean = (PageBean) session.getAttribute("pageBean");
		if(pageBean == null) {
			pageBean = new PageBean();
		}
		String page = request.getParameter("page");
		if(page != null && page != "") {
			pageBean.setPageOffset(Integer.parseInt(page));
		}
		Company company = Company.dao.findFirst("select count(*) total from company");
		int total = company.getLong("total").intValue();
		pageBean.setTotal(total);
		session.setAttribute("pageBean", pageBean);

		List<Company> experts =  Company.dao.find("select * from company ");
		return experts;
	}
}
